package com.java.mall_imooc.config;

import com.java.mall_imooc.interceoter.LoginInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 * @author jl
 * @since 2020-03-14 23:41:10
 */
@Configuration
@AllArgsConstructor
public class InterceptorConfig implements WebMvcConfigurer {

    private LoginInterceptor loginInterceptor;

    private WhitelistProperties whitelistProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //  /** 所有路径    /* 一级路径
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns(whitelistProperties.getAllowPaths());
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
